import request from '@/utils/request';
import { getParamsSuffix } from '@/utils/paramsUtils';

/**
 * 分页
 * @returns {Promise<any>}
 * @param params
 */
export async function getPageData(params) {
  return request(`/api/cdcerservice/v1/detaileddatareporting/listAllTableData`, {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 获取table的columns
 * @param query
 * @returns {Promise<any>}
 */
export async function listAllTableColumn(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/detaileddatareporting/listAllTableColumn?${params}`);
}

/**
 * 获取table的columns
 * @param query
 * @returns {Promise<any>}
 */
export async function listAllTableColumn4Office(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/detaileddatareporting/listAllTableColumn4Office?${params}`);
}

/**
 * 点击导出所有信息
 * @returns {Promise<any>}
 * @param params
 */
export async function queryAllExportData(params) {
  return request(`/api/cdcerservice/v1/detaileddatareporting/queryAllExportData`, {
    method: 'POST',
    requestType: 'form',
    responseType: 'blob',
    data: {
      ...params
    }
  });
}

/**
 * 点击批量删除
 * @returns {Promise<any>}
 * @param params
 */
export async function batchDeleteData(params) {
  return request('/api/cdcerservice/v1/detaileddatareporting/batchDeletion', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 获取table的columns
 * @param query
 * @returns {Promise<any>}
 */
export async function oneClickDeleteData(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/detaileddatareporting/oneClickDelete?${params}`);
}

/**
 * 点击存入正式库
 * @returns {Promise<any>}
 * @param query
 */
export async function insertOfficeInfo(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/detaileddatareportingOffice/insertOfficeInfo?${params}`);
}

/**
 * 获取table的columns
 * @returns {Promise<any>}
 * @param params
 */
export async function deleteById(params) {
  return request('/api/cdcerservice/v1/detaileddatareporting/deleteById', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 分页
 * @returns {Promise<any>}
 * @param params
 */
export async function getOfficePageData(params) {
  return request(`/api/cdcerservice/v1/detaileddatareportingOffice/getOfficePageData`, {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 点击导出所有信息
 * @returns {Promise<any>}
 * @param params
 */
export async function queryAllOfficeExportData(params) {
  return request(`/api/cdcerservice/v1/detaileddatareportingOffice/queryAllOfficeExportData`, {
    method: 'POST',
    requestType: 'form',
    responseType: 'blob',
    data: {
      ...params
    }
  });
}

/**
 * 查询记录
 * @param query
 * @returns {Promise<any>}
 */
export async function findDataById(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/detaileddatareportingOffice/findDataById?${params}`);
}

/**
 * 查询记录
 * @param query
 * @returns {Promise<any>}
 */
export async function findOfficeDataById(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/detaileddatareporting/findDataById?${params}`);
}

/**
 * 更新数据
 * @param params
 * @returns {Promise<any>}
 */
export async function updateRecord(params) {
  return request('/api/cdcerservice/v1/detaileddatareporting/updateRecord', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 图像文件解析
 * @param params
 * @returns {Promise<any>}
 */
export async function execFileParse(params) {
  return request('/api/cdcerservice/v1/detaileddatareporting/execFileParse', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}
